﻿using System;
using DateTimeFields.Model;
using NUnit.Framework;
using Xtensive.Orm;
using Xtensive.Orm.Configuration;

namespace DateTimeFields
{
    public class Program
    {
        [Test]
        public static void Main()
        {
            // Loading domain configuration section with name "Default".
            var domainConfiguration = DomainConfiguration.Load("Default");
            var domain = Domain.Build(domainConfiguration);

            using (var session = domain.OpenSession()) {
                using (var t = session.OpenTransaction()) {

                    // Jules Verne - Five Weeks in a Balloon
                    // http://en.wikipedia.org/wiki/Five_Weeks_in_a_Balloon
                    var flight = new Flight(session) {
                        Transport = "Balloon",
                        DepartureLocation = "Zanzibar",
                        DepartureDate = new DateTime(1862, 4, 18),
                        ArrivalLocation = "Senegal",
                        ArrivalDate = new DateTime(1862, 5, 24)
                    };
                    flight.Duration = flight.ArrivalDate - flight.DepartureDate; // 5 weeks

                    t.Complete();
                }
            }
        }
    }
}
